package ${package}.service;

import ${package}.entity.JcMyInfo;
import ${package}.dto.JcPage;
import ${package}.mapper.JcMyInfoMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
* @author Jevoncode
* @since 2018-12-16
*/
@Service
public class JcMyInfoServiceImpl implements JcMyInfoService {

    @Autowired
    private JcMyInfoMapper jcMyInfoMapper;
    
    @Override
    public int insert(JcMyInfo model) {
        return this.jcMyInfoMapper.insert(model);
    }

    @Override
    public int insertBatch(List<JcMyInfo> modelList) {
        return this.jcMyInfoMapper.insertBatch(modelList);
    }

	@Override
    public int update(JcMyInfo model) {
        JcMyInfo old = this.jcMyInfoMapper.getById(model.getId());
		if(old == null){
			return 0;
		}
        //理应将old输出日志，保证当时操作时数据是这样
        BeanUtils.copyProperties(model,old);
		return this.jcMyInfoMapper.update(old);
    }

    @Override
    public int updateSelective(JcMyInfo model) {
        JcMyInfo old = this.jcMyInfoMapper.getById(model.getId());
		if(old != null)
        	return this.jcMyInfoMapper.updateSelective(model);
		return 0;
    }

    @Override
    public JcMyInfo getById(Integer id){
        JcMyInfo model = this.jcMyInfoMapper.getById(id);
		return model;
    }

    @Override
    public JcPage queryList(JcPage page) {
        List<JcMyInfo> list = this.jcMyInfoMapper.queryList(page);
        page.setData(list);
        return page;
    }

    @Override
    public int count(Map<String,Object> params) {
		return this.jcMyInfoMapper.count(params);
    }

    @Override
    public List<JcMyInfo> findList(Map<String,Object> params){
        return this.jcMyInfoMapper.findList(params);
    }
}
